Search
woogc/single_checkout/split_order/order_created - WP Global Cart
17395
documentation-template-default,single,single-documentation,postid-17395,theme-awake,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-6.3.0,vc_responsive
 

woogc/single_checkout/split_order/order_created

WP Global Cart / woogc/single_checkout/split_order/order_created
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

woogc/single_checkout/split_order/order_created

Name: woogc/single_checkout/split_order/order_created
Type: Action
Arguments: $new_order

The `woogc/single_checkout/split_order/order_created` action is triggered when a new order is created as part of the split order process in WooCommerce Global Cart. This action is specifically used when the Single Site checkout type is enabled. During this process, the core functionality creates separate orders for products that belong to different shops within the cart.

When using the Split Order with Single Checkout type, WooCommerce Global Cart processes the checkout by splitting the cart’s contents into individual orders. Each order corresponds to the products that belong to a specific shop. This ensures that each shop manages its own orders independently, even though the customer experiences a unified checkout process.

Usage
The action can be used to perform additional tasks or customizations when a new split order is created. For example, developers can use this hook to:

– Send custom notifications to shop owners.
– Modify the order details.
– Perform custom logging or analytics.

Example
Here is an example of how to use the `woogc/single_checkout/split_order/order_created` action in your custom code:

    add_action('woogc/single_checkout/split_order/order_created', 'custom_function_on_order_created');
    function custom_function_on_order_created($new_order) 
        {
            // Your custom code here

            // Example: Add a custom meta field to the new order
            $new_order->add_meta_data('_custom_meta_key', 'custom_meta_value', true);
            $new_order->save();
        }

In this example, `custom_function_on_order_created` is a custom function that gets executed whenever a new split order is created. The `$new_order` argument represents the newly created order object, allowing you to interact with and manipulate the order as needed.

The following code example, removes the shipping information for the order:

    add_action('woogc/single_checkout/split_order/order_created', '_split_order_remove_shipping_items');
    function _split_order_remove_shipping_items ( $new_order ) 
        {

                // Get all items in the order
                $items = $new_order->get_items('shipping');

                // Loop through each item
                foreach ($items as $item_id => $item) {
                    // Remove the item
                    $new_order->remove_item($item_id);
                }

                // Save the order
                $new_order->save();
        }

Parameters
– `new_order` (`WC_Order`): The newly created order object.

Notes
– Ensure that your custom code is properly tested in a staging environment before deploying it to production.
– This action is specifically for use with the Single Site checkout type in WooCommerce Global Cart.

By leveraging the `woogc/single_checkout/split_order/order_created` action, developers can extend and customize the behavior of split orders, providing a tailored experience for each shop within the WooCommerce ecosystem.

0
Would love your thoughts, please comment.x
()
x